﻿
using System;
using System.Collections.Generic;

namespace NoNameGoServer.Client {
    public abstract class Error {
        public abstract Exception GetException();
    }

    public class ExceptionError : Error {
        public Exception Exception { get; private set; }

        public ExceptionError(Exception ex) {
            Exception = ex;
        }

        public override Exception GetException() {
            return Exception;
        }
    }

    public class MultipleErrorsError : Error {
        private List<Error> Errors { get; set; }

		public MultipleErrorsError() {
			Errors = new List<Error>();
		}

        public void Add(Error error) {
            Errors.Add(error);
        }

        public override Exception GetException() {
            List<Exception> exceptions = new List<Exception>();
            foreach (Error error in Errors) {
                exceptions.Add(error.GetException());
            }
            return new MultiException(exceptions.ToArray());
        }
    }
}
